<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>车辆维修</title>
    <link rel="stylesheet" href="UC_style.css">
    <style>
        .main {
            width: 100%;
            height: 800px;
            background: RGB(239,239,239);
            float: left;
        }

        #header2 {
            height: 40px;
            background: white;
        }

        table,
        th,
        td {
            background-color: white;
            border: 1px solid black;
            border-collapse: collapse;
        }

        td {
            width: 200px;
            height: 90px;
            padding: 5px;
        }

        th {
            font-size: 18px;
        }

        .had {
            text-align: center;
            vertical-align: middle;
            height: 600px;
            width: 80%;
            margin: 0px auto;
        }

        .input1 {
            border: 0px;
            height: 90%;
            font-size: 16px;
            width: 100%;
            outline: none;
            text-align:center;
        }

        h2 {
            text-align: center;
        }

        .input2 {
            color: black;
            background-color: RGB(239,239,239);
            font-size: 20px;
            height: 40px;
            width: 100px;
            margin-left: 450px;
            margin-right: 30px;
        }

            .input2:hover {
                background-color: #808080;
            }
		label {
  			display: inline-block;
  			vertical-align: middle;
  			margin-right: 5px;
		}
		.input3 {
  			display: inline-block;
  			vertical-align: middle;
  			width:50%;
  			height:100%;
  			border: none;
  			outline: none;
  			font-size: 18px;
		}            
    </style>
</head>

<body>
<%
	String repair_id=request.getParameter("id");//取得传递过来的用户参数，用于查询和删除
	Connection conn=null;
	String sql="select * from car_repair where repair_id='"+repair_id+"'";
	try{
		Class.forName("org.h2.Driver");//加载驱动
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
		return;
	}
	try {
		conn = DriverManager.getConnection("jdbc:h2:d:/CompanyCar/temp/mydbtest", "sa", "");
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery(sql);
		if(rs!=null && rs.next()){//执行完sql语句后，rs指向第一条结果的前面，所以必须执行一次next()操作
			System.out.println("right");
		}
		else
		{	
			System.out.println("null");
		}
%>
    <div class="main">
        <div id="header2">
            <img src="img/frist.png" alt="Big Boat" width="30" height="30" style=" vertical-align: middle;">
            车辆维修 > 信息查看
        </div>
        <h2>车辆维修表</h2>
        <%String editURL="D-JDBC-Details_repair_edit.jsp?action=2&id="+rs.getInt("repair_id"); %>
        <form id="myForm" action=<%=editURL %> method="post">
            <table class="had">
                <thead>
                    <tr>
                        <th>车辆名称</th>
                        <td><input class="input1" name="car_name" type="text" value=<%=rs.getString("car_name") %> readonly></td>
                        <th>车牌号</th>
                        <td><input class="input1" name="license_plate" type="text" value=<%=rs.getString("license_plate") %> readonly></td>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <th>序号</th>
                        <th>维修类别</th>
                        <th>费用</th>
                        <th>理由</th>
                    </tr>
                </tbody>

                <tfoot>
                    <tr>
                        <td><input class="input1" type="text" value="1" readonly></td>
                        <td><input class="input1" name="repair_type1" type="text" value=<%=rs.getString("repair_type") %> readonly></td>
                        <td><input class="input1" name="repair_cost1" type="text"  value=<%=rs.getFloat("repair_cost") %> readonly></td>
                        <td><input class="input1" name="repair_reason1" type="text" value=<%=rs.getString("repair_reason") %> readonly></td>
                    </tr>
                    <tr>
                        <td><input class="input1" type="text" value="2" readonly></td>
                        <td><input class="input1" name="repair_type2" type="text" readonly></td>
                        <td><input class="input1" name="repair_cost2" type="text" readonly></td>
                        <td><input class="input1" name="repair_reason2" type="text" readonly></td>
                    </tr>
                    <tr>
                        <td><input class="input1" type="text" value="3" readonly></td>
                        <td><input class="input1" name="repair_type3" type="text" readonly></td>
                        <td><input class="input1" name="repair_cost3" type="text" readonly></td>
                        <td><input class="input1" name="repair_reason3" type="text" readonly></td>
                    </tr>
                    <tr>
                        <td><input class="input1" type="text" value="4" readonly></td>
                        <td><input class="input1" name="repair_type4" type="text" readonly></td>
                        <td><input class="input1" name="repair_cost4" type="text" readonly></td>
                        <td><input class="input1" name="repair_reason4" type="text" readonly></td>
                    </tr>
					<tr>
						<td><label for="applicant">经办人：</label> 
						<input class="input3" type="text" name="applicant" value=<%=rs.getString("repair_person") %> readonly></td>
						<td><label for="transportation-manager">运输部负责人：</label> 
						<input class="input3" type="text" id="transportation-manager" placeholder="请签名" required value=<%=rs.getString("transport_department_person") %> ></td>
						<td colspan="2">
							<label for="lookfile">资料附件：</label> 
								<input type="text" class="input3" style="width:70%;" name="lookfile" id="lookfile" readonly>
								<input type="button" value="上传文件" >
								<input type="file"  name="data_attachment" id="path" style="display:none" onchange="lookfile.value=this.value" >
						</td>
						
					</tr>
				</tfoot>
            </table>
			<%
				rs.close();
				stmt.close();
				//关闭表达式对象				
				conn.close();

				} catch (SQLException e) {
					e.printStackTrace();
				} finally {
				//防止数据库未正常关闭
					try {
						if (conn != null && (!conn.isClosed())) {
							conn.close();
					}
					} catch (SQLException e) {
						e.printStackTrace();
					}
				}
			%>
            <br>
            <input type="submit" class="input2" value="审批完成">
            <input type="button" class="input2" onclick="Return()" value="返回">
        </form>
    </div>

<script>
	function Return(){
		window.location.href="D-Details_repair.jsp";
}
</script>
</body>
</html>
